package leetcode.每日一题;

import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2021/12/10 12:12
 * @description：https://leetcode-cn.com/problems/rotate-image/
 */
public class 旋转图像 {
    @Test
    public void test() {
        Solution solution = new Solution();
    }

    class Solution {
        public void rotate(int[][] matrix) {
            int m = matrix.length;
            // 水平反转
            for (int i = 0; i < m / 2; i++) {
                for (int j = 0; j < m; j++) {
                    int tmp = matrix[i][j];
                    matrix[i][j] = matrix[m - i - 1][j];
                    matrix[m - i - 1][j] = tmp;
                }
            }
            // 主对角线反转
            for (int i = 0; i < m; i++) {
                for (int j = 0; j < i; j++) {
                    int tmp = matrix[i][j];
                    matrix[i][j] = matrix[j][i];
                    matrix[j][i] = tmp;
                }
            }
        }
    }

}
